package neo.aoi;

import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;

import artofillusion.Scene;
import artofillusion.Translator;

/**
 * Voxel exporter plugin class. This class serves as a plugin for Art of
 * illusion and exports data in a voxel format which can then be loaded in
 * matlab. The output is a file which contains matlab matrices which represent
 * the 'Occupancy Grid' of the exported object.
 * 
 * @author Carlos Martinez
 */
public class VoxelTranslator implements Translator {

	/**
	 * Specify whether this translator can export files.
	 * 
	 * @return Always true
	 */
	public boolean canExport() {
		return true;
	}

	/**
	 * Specify whether this translator can import files.
	 * 
	 * @return Always false
	 */
	public boolean canImport() {
		return false;
	}

	/**
	 * Prompt the user for a filename and any other necessary information, and
	 * export the scene. A progress bar is displayed while the process Scene is
	 * being exported
	 */
	public void exportFile(buoy.widget.BFrame parent, Scene theScene) {
		VoxelExporter.ExportParameters params = VoxelExporter
				.getExportParameters(parent);

		if (params.proceed()) {
			// Launch GUI progress bar
			ExportProgressBar bar = new ExportProgressBar(parent);
			SwingWorker worker = new VoxelExportTask(params, theScene, parent,
					bar);
			SwingUtilities.invokeLater(bar);
			worker.execute();
		}
	}

	/**
	 * Get the name of the file format which this translator imports or exports.
	 */
	public String getName() {
		return "Voxel Exporter";
	}

	/**
	 * Prompt the user to select a file, read it, and create a new LayoutWindow
	 * containing the imported scene.
	 */
	public void importFile(buoy.widget.BFrame parent) {
	}
}
